package cn.com.lyb.flink.source;

import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.connector.file.src.FileSource;
import org.apache.flink.connector.file.src.reader.TextLineInputFormat;
import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class FileSourceDemo {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        // 读文件
        FileSource.FileSourceBuilder<String> fileSource = FileSource.forRecordStreamFormat(new TextLineInputFormat(),
                new Path("D:\\tool\\idea_code\\lyb_alone\\flink1.17.0\\input\\words.txt"));
        FileSource<String> build = fileSource.build();
        env.fromSource(build, WatermarkStrategy.noWatermarks(),"name")
                .print();
        env.execute();
    }
}
/*
 新的source 写法
 env.formSource(Source的实现类， Wateramark，名字)
 */